class Solution:
    def minimumOneBitOperations(self, n: int) -> int:
        if n == 0:
            return 0
        x = len(bin(n)) - 3
        return (1 << (x + 1)) - 1 - self.minimumOneBitOperations(n - (1 << x))

